<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>访问对象属性</h2>
    <ul>
        <li>使用对象名.属性名，访问对象的属性。</li>
    </ul>
    <script>
        let people = {
            name: "奉先",
            age: 35,
            showName: function() {
                console.log("奉先");
            }
        }
        // 访问值
        console.log("people.name = ",people.name);
        // 如果是方法，可以加()进行调用。
        people.showName();

        // 修改值
        people.age = 40;
        console.log("people.age = ",people.age);

        // 对象的属性没有赋值，也可以访问，返回为undefined
        console.log("people.sex = ",people.sex);
        // 我们可以直接给对象的属性赋值，无论它现在是否存在
        people.sex = "男";
        console.log("people.sex = ",people.sex);
        
    </script>
</body>
</html>